<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
       /* 在关闭窗口或标签页之后将会删除这些数据 */ 
       //1.保存数据
       localStorage.setItem("name","curry");
       
       //2.提取数据
       localStorage.getItem("name");

       //3.删除数据
       localStorage.removeItem("name");

       /* 多样化操作 */
       //1.三种方式保存数据
       localStorage["a"] = 1;
       localStorage.b = 2;
       localStorage.setItem("c",3);

       //2.查看数据类型
       console.log( typeof localStorage["a"] ); //string
       console.log( typeof localStorage["b"] ); //string
       console.log( typeof localStorage["c"] ); //string

       //3.1 第一种方式读取
       var a = localStorage.a;
       console.log(a); //1

       //3.2 第二种方式读取
       var b = localStorage["b"];
       console.log(b); //2

       //3.3 第三种方式读取
       var c = localStorage.getItem("c");
       console.log(c); //3

    </script>
</body>
</html>